﻿@model PessMvc.Models.ArchivesModel

@{
    ViewBag.Title = "Proposals";
}

<h2>My Proposals</h2>
<div id="operate">
    @if (ViewBag.IsArchiveModificationAllowed) { 
        @Html.ActionLink("New Proposal", "CreateProposal")
        }
        else
    {
        <span>Submission Closed</span>
    }
</div>
@if(Model.All.Count>0)
        {
<div class="displayConScroe">
    <table style="border-color:#ccc;">
        @foreach (var item in Model.All)
        {
            <tr>
                <td style="border-color:#ccc;text-align:left">
                    <fieldset style="margin-bottom: 0px; background-color: transparent; border: none; -webkit-box-shadow: none; box-shadow:none;">
                        <legend></legend>
                        <div class="displayHead">
                            @Html.DisplayFor(modelItem => item.CalculatedSerialNumber): @Html.DisplayFor(modelItem => item.ProjectTitle)
                        </div>

                        <div class="displayDesc_long">
                            Authors：@foreach (var pa in item.PAuthorsInOrder)
                                     {
                                       @Html.DisplayFor(modelItem => pa.Name)<text>;</text> 
                                     }
                        </div>

                        <div class="displayYear">
                            Format：@Html.DisplayFor(modelItem=>item.County.Name)
                        </div>

                        <div class="displayYear">
                            @{var statusName = Enum.GetName(typeof(PessModel.ArchiveStatus), item.Status);}
                            Proposal Review Status：@Html.DisplayFor(modelItem => statusName)
                        </div>
                        <div class="displayDTime">
                            Paper Review Status: @Html.DisplayFor(modelItem=>item.PaperStatusName)
                        </div>
                        <div class="displayDTime_long">
                            Track: @Html.DisplayFor(modelItem=>item.Subject.Track.Title)
                        </div>

                        <div class="displayDTime_long">
                            Topic: @Html.DisplayFor(modelItem=>item.Subject.Name)
                        </div>

                        <div style="clear:both;padding-top:20px;text-align:left;width:100%">
                            @Html.ActionLink("Review Proposal", "Details", new { id = item.ID })
                            @{
                                MembershipUser user=Membership.GetUser();
                                Guid? authorUserID=new Guid(user.ProviderUserKey.ToString());
                              }
                            @if (item.UserID == authorUserID) { 
                                if (ViewBag.IsArchiveModificationAllowed&&item.Status==2) {                                
                                    @Html.ActionLink("Edit Proposal", "EditProposal", new { id = item.ID })
                                }
                                else if (ViewBag.IsArchiveModificationAllowed && item.Status ==4&&item.PaperStatus<2)
                                {
                                    @Html.ActionLink("Change Authors", "ChangeAuthors", "PAuthor", new { id = item.ID }, null)
                                }
                                if (ViewBag.IsPaperUploadAllowed && item.Status == 4 && (item.PaperStatus < 2 || item.PaperStatus > 5))
                                {
                                    if (item.PaperStatus < 2) 
                                    { 
                                        @Html.ActionLink("Upload Paper", "UploadPaper", new { id = item.ID }) 
                                    }
                                    else
                                    {
                                        @Html.ActionLink("Upload Final Paper", "UploadPaper", new { id = item.ID }) 
                                    }
                                }
                                                       
                            
                                if (ViewBag.IsArchiveModificationAllowed&&item.Status==2) {
                                    @Html.ActionLink("Cancel Proposal", "Delete", new { id = item.ID }) 
                                }
                            }
                            @if (item.Status >= 4)
                            {
                            @Html.ActionLink("Proposal Feedback", "ReviewFeedback", new { id = item.ID })
                            }
                            @if (item.PaperStatus >= 4)
                            {
                            @Html.ActionLink("Paper Feedback", "ReviewPaperFeedback", new { id = item.ID })
                            }
                        </div>

                    </fieldset>
                </td>
            </tr>
        }
    </table>
</div>
}
else
{
     <div style="clear:both;float:none;font-size:16px;padding-top:20px;">We haven't received proposals from you. 
    @if (ViewBag.IsArchiveModificationAllowed)
    {
        <span>Click @Html.ActionLink("here", "CreateProposal") to submit a new proposal.</span>
    } 
    @*else
    {
        <span>We accept new proposals from  </span>
    }*@
    </div>
}